class SaleOrderDetail < ActiveRecord::Base
  
  belongs_to :sale_order
  belongs_to :product

  #scope :filter_by_product_suit, lambda { |saleOrderId,isSuit| joins(:product).where("sale_order_details.product_id = products.id AND sale_order_details.sale_order_id = ? AND products.is_suit = ?" ,saleOrderId,isSuit) }
  #scope :filter_by_product_suit, lambda { |saleOrderId| joins(:product)&Product.is_not_suit.where("sale_order_details.sale_order_id = ?" ,saleOrderId) }
  scope :filter_by_product_suit, lambda { |saleOrderId| joins(:product).merge(Product.is_not_suit).where("sale_order_details.sale_order_id = ?" ,saleOrderId) }
  
end
